﻿using System.Collections.Generic;
using System.Text;

namespace Core.Library
{
    public class TagBuilder
    {
        StringBuilder html = new StringBuilder();
        string tagtype;
        List<StringBuilder> TagAttribute = new List<StringBuilder>();
        public TagBuilder(string tagtype)
        {
            this.tagtype = tagtype;
        }
        public void MergeAttribute(string attr, string value)
        {
            var attrhtml = new StringBuilder();
            attrhtml.Append(attr);
            attrhtml.Append("=\"");
            attrhtml.Append(value);
            attrhtml.Append("\"");
            TagAttribute.Add(attrhtml);

        }
        public string InnerHtml { get; set; }
        public override string ToString()
        {
            var tag = new StringBuilder();
            tag.Append("<li><");
            tag.Append(tagtype);
            tag.Append(" ");
            foreach (var attr in TagAttribute)
            {
                tag.Append(attr.ToString());
            }
            tag.Append(">");
            tag.Append(this.InnerHtml);
            tag.Append("</");
            tag.Append(tagtype);
            tag.Append("></li>");
            return tag.ToString();
        }
    }
}
